package _binary_search;

/**
 * 275. H 指数 II
 */
public class No275 {
    public int hIndex(int[] citations) {
        int n = citations.length;

        int left = 0, right = n - 1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (citations[mid] < n - mid) left = mid + 1;
            else right = mid - 1;
        }

        return n - left;
    }
}
